<% // Copyright 2008 Carnegie Mellon University
// Licensed under the Apache License, Version 2.0 (the "License"); 
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//  
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, 
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License. %>

<%@page import="java.sql.*"%>
<%@page import="edu.cmu.lti.sepia.util.*"%>
<%@page import="edu.cmu.lti.sepia.data.session.SessionManager"%>
<%@page import="edu.cmu.lti.sepia.data.resource.ResourceManager"%>

<%@page language="java" contentType="text/html; charset=UTF-8" %>
<%@page pageEncoding="UTF-8" %> 

<%
 response.setHeader("progma", "no-cache");
 response.setHeader("Cache-Control", "no-cache");
 request.setCharacterEncoding("UTF8");

 String errorMessage = ResourceManager.init();
 boolean sepiaHomeInvalid = errorMessage.length()>0;

 //TODO: remove hardcode
 //we need dummy ones too for the resource.js.jsp
 session.setAttribute("language", "EN");
 session.setAttribute("userName", "");
 session.setAttribute("userId", -1);
 session.setAttribute("taskName", "");
 session.setAttribute("taskNameShort", "");
 session.setAttribute("isMonolingual", false);
 session.setAttribute("types", new String[0]);
 session.setAttribute("host", request.getRemoteHost());
 %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Standard Evaluation Package for Information Access Setup</title>
</head>
<body>

<%
if( ResourceManager.initializedAlready() ) {
%>  
  <h1>Set up is already done.</h1>
  Please delete the property file SEPIA_HOME/sepia.properties to initialize the system.
<%
} else {
%>
<h1>Welcome to SEPIA setup wizard.</h1>
<%
if ( sepiaHomeInvalid ) { // if invalid
  %>
  <strong>Following error occurred.</strong>
  <ul><%=errorMessage%></ul>
  <%
} else {
%>

Read the license agreement below, click on the agreement checkbox and click on continue:<br>
<textarea cols="80" rows="15">
Copyright 2008 Carnegie Mellon University
Licensed under the Apache License, Version 2.0 (the "License"); 
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, 
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License. 
</textarea><br>
<br>
<input type="checkbox" id="agree" onchange="document.getElementById('continue').disabled=!this.checked">&nbsp;&nbsp;<label for="agree">I've read and agree to the statement above.</label>
<br>
<!-- 
Choose the language to display setup messages 
<select>
<option>ENGLISH</option>
<option>JAPANESE</option>
<option>CHINESE (Simplified)</option>
<option>CHINESE (Traditional)</option>
</select>
<br><em>(Note: Hideki is currently working on this funtion)</em>
-->
<br>
<input id="continue" type="button" value=" Continue" onclick="top.location.href='project_manager.jsp'" disabled>

<%
} // if valid
%>

<%
} // if already set up 
%>

</body>
</html>